package bookTrading.seller;

import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

@SuppressWarnings("serial")
public class SellerInform extends CyclicBehaviour
{
	private AgentSeller agentSeller;


	// Construtor
	public SellerInform(AgentSeller agentSeller)
	{
		this.agentSeller = agentSeller;
	}


	@Override
	public void action()
	{
		MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
		ACLMessage msg = agentSeller.receive(mt);

		if (msg != null)
		{
			System.out.println("[Inform] Comprador diz: " + msg.getContent());
			
			ACLMessage reply = msg.createReply();

			reply.setPerformative(ACLMessage.INFORM);
			reply.setContent("Obrigado pela Compra!");

			agentSeller.send(reply);
			agentSeller.doDelete();
		}
	}
}